package com.ss.android.article.base.ui;

import android.animation.ValueAnimator;
import android.content.Context;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.LinearInterpolator;
import android.view.animation.ScaleAnimation;
import android.view.animation.TranslateAnimation;
import android.widget.AbsListView;
import com.bytedance.common.utility.UIUtils;
import com.handmark.pulltorefresh.library.PullToRefreshBase.State;
import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.ss.android.article.browser.R;

public final class NotifyViewHelper {
    View a;
    ValueAnimator b;
    int c;
    private Context d;

    public NotifyViewHelper(Context arg3) {

        this.d = arg3;
        this.c = this.d.getResources().getDimensionPixelOffset(R.dimen.notify_view_height);
    }

    public final void a(View arg10) {
        boolean v0 = arg10 == null || arg10.getVisibility() != View.VISIBLE || this.a == null || this.a.getVisibility() != View.VISIBLE || this.a.getParent() == null ? false : true;
        this.a(v0);
        if(arg10 != null && arg10.getVisibility() == View.VISIBLE) {
            if(!v0) {
                UIUtils.setVisibility(arg10, 8);
            }
            else {
                TranslateAnimation v0_1 = new TranslateAnimation(1, 0f, 1, 0f, 1, 0f, 1, -1f);
                v0_1.setDuration(200);
                v0_1.setInterpolator(new LinearInterpolator());
                v0_1.setAnimationListener(new af(arg10));
                arg10.clearAnimation();
                arg10.startAnimation(((Animation)v0_1));
            }
        }
    }

    public final View a() {
        if(this.a == null) {
            this.a = new View(this.d);
            this.a.setLayoutParams(new AbsListView.LayoutParams(-1, 0));
            this.a.setVisibility(View.GONE);
        }

        return this.a;
    }

    public final void a(PullToRefreshBase pullToRefreshBase, int arg5, int arg6) {
        if(pullToRefreshBase != null && arg6 == 0 && arg5 != 0) {
            int v0 = this.c();
            if(v0 > 0) {
                if(pullToRefreshBase.getState() != State.MANUAL_REFRESHING) {
                    pullToRefreshBase.b(-v0);
                }

                this.a(false);
            }
        }
    }

    private void a(boolean arg5) {
        if(this.a != null && this.a.getVisibility() == View.VISIBLE) {
            if(!arg5) {
                UIUtils.setLayoutParams(this.a, -3, 0);
                UIUtils.setVisibility(this.a, 8);
            }
            else {
                if(this.b == null) {
                    this.b = ValueAnimator.ofInt(new int[]{this.c, 0}).setDuration(200);
                    this.b.addListener(new ar(this.a, new ag(this)));
                    this.b.addUpdateListener(new as(this.a));
                    this.b.setInterpolator(new LinearInterpolator());
                }
                else {
                    this.b.cancel();
                }

                this.b.start();
            }
        }
    }

    public final void b(View arg10) {
        float v2 = 1f;
        float v1 = 0.8f;
        float v6 = 0.5f;
        if(arg10 != null) {
            UIUtils.setVisibility(arg10, 0);
            ScaleAnimation v0 = new ScaleAnimation(v1, v2, v1, v2, 1, v6, 1, v6);
            v0.setDuration(300);
            v0.setInterpolator(new ao());
            arg10.clearAnimation();
            arg10.startAnimation(((Animation)v0));
            this.b();
        }
    }

    public final void b() {
        if(this.a != null) {
            this.a.post(new ah(this));
        }
    }

    public final int c() {
        int v0 = this.a == null || this.a.getVisibility() != View.VISIBLE ? 0 : this.a.getHeight();
        return v0;
    }

    public final void d() {
        if(this.b != null) {
            this.b.removeAllUpdateListeners();
            this.b.removeAllListeners();
            this.b.cancel();
        }
    }
}

